<div class="footer">
    <nav class="footer-bar">
        <div class="tab-item">
            <a href="{:url('/')}">
                <span class="mui-icon mui-icon-home"></span>
                <span class="mui-tab-label">首页</span>
            </a>
        </div>
        <div class="tab-item">
            <a href="{:url('/home/index/search')}">
                <span class="mui-icon mui-icon-search"></span>
                <span class="mui-tab-label">搜索</span>
            </a>
        </div>
        <div class="tab-item">
            <a href="{:url('/home/subject/teacher/index')}">
                <span class="iconfont teacher">&#xe63a;</span>
                <span class="mui-tab-label">名师</span>
            </a>
        </div>
        <div class="tab-item">
            <a href="{:url('/home/business/index')}">
                <span class="mui-icon mui-icon-contact"></span>
                <span class="mui-tab-label">我的</span>
            </a>
        </div>
    </nav>
</div>


<script>
    let path = location.pathname;
    // console.log(path);
    pathArr = path.split('/');         //通过'/'转化成数组
    // console.log(pathArr);
    pathArr = pathArr.filter((value) => {   //过滤空数组元素
        return value && $.trim(value);
    })
    pathArr.pop();
    // console.log(pathArr);
    path = pathArr.join('/');              //通过'/'转化成字符串
    // console.log(path);

    if (path === '' || path === '/') {
        $($('.footer-bar .tab-item')[0]).addClass('mui-active');
        console.log($('.footer-bar .tab-item'));
    } else if (path === 'home/index') {
        $($('.footer-bar .tab-item')[1]).addClass('mui-active');
    } else if (path === 'home/subject/teacher') {
        $($('.footer-bar .tab-item')[2]).addClass('mui-active');
    }else if (path === 'home/business') {
        $($('.footer-bar .tab-item')[3]).addClass('mui-active');
    }
    // console.log($('.footer-bar .tab-item'));

</script>